package com.gitee.jmliu1983.finacehelper.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.gitee.jmliu1983.finacehelper.domain.VFundNewst;
import com.gitee.jmliu1983.finacehelper.service.IVFundNewstService;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;


/**
 * fund_new_priceController
 * 
 * @author jm
 * @date 2025-02-27
 */
@RestController
@RequestMapping("/fund_now")
@PreAuthorize("@ss.hasRole('finace')")
public class VFundNewstController extends BaseController
{
    @Autowired
    private IVFundNewstService vFundNewstService;

    /**
     * 查询fund_new_price列表
     */
//    @RequiresPermissions("fund_now:fund_now:list")
    @GetMapping("/list")
    public TableDataInfo list(VFundNewst vFundNewst)
    {
        startPage();
        List<VFundNewst> list = vFundNewstService.selectVFundNewstList(vFundNewst);
        return getDataTable(list);
    }

    /**
     * 导出fund_new_price列表
     */
//    @RequiresPermissions("fund_now:fund_now:export")
    @Log(title = "fund_new_price", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, VFundNewst vFundNewst)
    {
        List<VFundNewst> list = vFundNewstService.selectVFundNewstList(vFundNewst);
        ExcelUtil<VFundNewst> util = new ExcelUtil<VFundNewst>(VFundNewst.class);
        util.exportExcel(response, list, "fund_new_price数据");
    }

    /**
     * 获取fund_new_price详细信息
     */
//    @RequiresPermissions("fund_now:fund_now:query")
    @GetMapping(value = "/{productId}")
    public AjaxResult getInfo(@PathVariable("productId") String productId)
    {
        return success(vFundNewstService.selectVFundNewstByProductId(productId));
    }

    /**
     * 新增fund_new_price
     */
//    @RequiresPermissions("fund_now:fund_now:add")
    @Log(title = "fund_new_price", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody VFundNewst vFundNewst)
    {
        return toAjax(vFundNewstService.insertVFundNewst(vFundNewst));
    }

    /**
     * 修改fund_new_price
     */
//    @RequiresPermissions("fund_now:fund_now:edit")
    @Log(title = "fund_new_price", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody VFundNewst vFundNewst)
    {
        return toAjax(vFundNewstService.updateVFundNewst(vFundNewst));
    }

    /**
     * 删除fund_new_price
     */
//    @RequiresPermissions("fund_now:fund_now:remove")
    @Log(title = "fund_new_price", businessType = BusinessType.DELETE)
	@DeleteMapping("/{productIds}")
    public AjaxResult remove(@PathVariable String[] productIds)
    {
        return toAjax(vFundNewstService.deleteVFundNewstByProductIds(productIds));
    }
}
